package libraServer;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import libra.model.Provider_Pay;
import libraServer.dao.Dao;

@Service
public class ProviderReqService {
	@Autowired
	Dao dao;
	@Autowired
	JdbcTemplate jt;
	
	String tableName = Provider_Pay.class.getSimpleName().toLowerCase();
	
	public void SavePay( Provider_Pay pay ) throws Exception {
		dao.save(pay);
	}
	
	public Provider_Pay QueryOne( int id ) {
		return dao.findByPK(Provider_Pay.class, id);
	}
	
	public List<Provider_Pay> QueryPayList() throws Exception {
		return dao.find(Provider_Pay.class, String.format("select * from %s", tableName), new Object[] {});
	}

	public void clearTablePay() {
		jt.execute(String.format("truncate table %s", tableName));
	}
}
